package se.gala.core;

import se.gala.api.CommandConstructor;
import se.gala.api.MessageBroadcaster;
import se.gala.utils.GGObject;

/**
 * This class serves to hold references to all central components.
 */
public final class Agora extends GGObject {
	
	// XXX remove these ugly test constants
	public static final String DUMMY_username_valid = "Valyo"; 
	public static final String DUMMY_username_invalid = "inValyo"; 
	public static final String DUMMY_password_valid = "parola"; 
	public static final String DUMMY_password_invalid = "parzhola"; 
	
	private static MessageBroadcaster broadcaster;
	private static CommandConstructor constructor;
	private static GameDispatcher gameDispatcher;

	public static void setGameDispatcher(GameDispatcher gameDispatcher) {
		if (Agora.gameDispatcher == null) {
			Agora.gameDispatcher = gameDispatcher;
		} else {
			throw new InitialisationException("GameDispatcher is already set");
		}
	}

	public static GameDispatcher getGameDispatcher() {
		return gameDispatcher;
	}

	public static void setBroadcaster(MessageBroadcaster broadcaster) {
		if (Agora.broadcaster == null) {
			Agora.broadcaster = broadcaster;
		} else {
			throw new InitialisationException("MessageBroadcaster is already set");
		}
	}

	public static MessageBroadcaster getBroadcaster() {
		return broadcaster;
	}

	public static void setConstructor(CommandConstructor constructor) {
		if (Agora.constructor == null) {
			Agora.constructor = constructor;
		} else {
			throw new InitialisationException("CommandConstructor is already set");
		}
	}

	public static CommandConstructor getConstructor() {
		return constructor;
	}
	
}
